import { onMounted, onUnmounted } from 'vue'

function useEventListener(target, eventName, handler) {
  onMounted(() => {
    console.log('useEventListener onMounted')
    target.addEventListener(eventName, handler, false)
  })

  onUnmounted(() => {
    console.log('useEventListener onUnmounted')
    target.removeEventListener(eventName, handler, false)
  })
}

export default useEventListener
